package com.nbsaas.sample.topic.rest.resource;

import com.nbsaas.sample.topic.api.apis.TopicApi;
import com.nbsaas.sample.entity.topic.Topic;
import com.nbsaas.sample.topic.api.domain.request.TopicDataRequest;
import com.nbsaas.sample.topic.api.domain.response.TopicResponse;
import com.nbsaas.sample.topic.api.domain.simple.TopicSimple;
import com.nbsaas.sample.topic.rest.convert.TopicSimpleConvert;
import com.nbsaas.sample.topic.rest.convert.TopicEntityConvert;
import com.nbsaas.sample.topic.rest.convert.TopicResponseConvert;
import com.nbsaas.sample.topic.data.repository.TopicRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;

/**
*   业务接口实现
*/
@Transactional
@Service
public class TopicResource extends BaseResource<Topic,TopicResponse, TopicSimple, TopicDataRequest>  implements TopicApi {

    @Resource
    private TopicRepository topicRepository;

    @Override
    public JpaRepositoryImplementation<Topic, Serializable> getJpaRepository() {
        return topicRepository;
    }

    @Override
    public Function<Topic, TopicSimple> getConvertSimple() {
        return new TopicSimpleConvert();
    }

    @Override
    public Function<TopicDataRequest, Topic> getConvertForm() {
        return new TopicEntityConvert();
    }

    @Override
    public Function<Topic, TopicResponse> getConvertResponse() {
        return new TopicResponseConvert();
    }

}


